<?php

class Privatbank extends AbstractParser
{

	protected $_url = 'http://privatbank.ua/business/';

	public function getRow($html)
	{
		$result = array();
		
		$html = $this->_cutSpaces( $html );

//        echo $html; exit;

		$pattern = '<h1.*class="product-name".*>(.*)</h1>';
		$matched = $this->_match( $pattern, $html );
//        print_r($matched); exit;
		
		if(empty($matched[1][0]))
			return $result;

        return $this->_addRow($result);
	}

    public function getNextPage($html)
    {
        return false;
    }

    public function getRowset($html)
    {
        $result = array();

        $html = $this->_cutSpaces( $html );

//        echo $html; exit;

        $pattern = '<table id="course-table-pb">(.*)</table>';
        $matched = $this->_match( $pattern, $html );
//        print_r($matched); exit;

        if(empty($matched[1][0]))
            return $result;

        $listHtml = $matched[1][0];

        //print_r($matched); exit;

        $pattern = '<tr><td width="26%">(.*)</td><td width="9%" style="text-align:right;">(.*)</td><td width="25%" style="text-align:right;">(.*)</td></tr>';
        $matched = $this->_match( $pattern, $listHtml );

//        print_r($matched); exit;

        if(empty($matched[1]) || empty($matched[3]))
            return $result;

        foreach($matched[1] as $i => $title)
        {
            $oRow =  clone $this->_oParserRow;

            $oRow->title = $title;
            $oRow->short = $title;
            $oRow->rate = $matched[3][$i];

            $this->_rowset[] = $oRow;
        }

        $aReturn['rowset'] = $this->_addRowset($result);

        return $aReturn;
    }

    public function getItem($html)
    {}

}